package common;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfSmartCopy;

import java.io.FileOutputStream;
import java.io.IOException;

public class Pdf_Example {


    public static void manipulatePdf(String src, String dest) throws IOException, DocumentException {
        PdfReader reader = new PdfReader(src);
        Document document = new Document();
        PdfCopy copy = new PdfSmartCopy(document, new FileOutputStream(dest));
        document.open();
        copy.addPage(copy.getImportedPage(reader, 1));
        document.close();
        reader.close();
    }


    public static void main(String[] args) throws DocumentException, IOException {
        Pdf_Example.manipulatePdf("C:\\Users\\hongtang.yang\\Documents\\企知道\\需求文档\\16查研报\\2022年维正企知道员工体检须知(1).pdf", "C:\\Users\\hongtang.yang\\Documents\\企知道\\需求文档\\16查研报\\copy.pdf");
    }

}

